home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / share / ibus / setup / icon.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2009-11-11  |  1KB  |  34 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __all__ = 'load_icon'
  5. import gtk
  6. from gtk import gdk
  7. from os import path
  8. icon_theme = gtk.icon_theme_get_default()
  9. dir = path.dirname(__file__)
  10. icondir = path.join(dir, '..', 'icons')
  11. icon_theme.prepend_search_path(icondir)
  12. icon_cache = { }
  13.  
  14. def load_icon(icon, size):
  15.     if (icon, size) in icon_cache:
  16.         return icon_cache[(icon, size)]
  17.     icon_size = gtk.icon_size_lookup(size)[0]
  18.     pixbuf = None
  19.     
  20.     try:
  21.         pixbuf = gdk.pixbuf_new_from_file(icon)
  22.         w = pixbuf.get_width()
  23.         h = pixbuf.get_height()
  24.         rate = max(w, h) / float(icon_size)
  25.         w = int(w / rate)
  26.         h = int(h / rate)
  27.         pixbuf = pixbuf.scale_simple(w, h, gdk.INTERP_BILINEAR)
  28.     except:
  29.         (icon, size) in icon_cache
  30.  
  31.     icon_cache[(icon, size)] = pixbuf
  32.     return pixbuf
  33.  
  34.